package com.ymatou.iapi.liveseller.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymatou.iapi.liveseller.parameter.CreateSellerPreVideoBean;
import com.ymatou.iapi.liveseller.parameter.ScanSysCloseLiveBean;
import com.ymatou.iapi.liveseller.service.ScanSysCloseLiveCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
/**
*job扫描已失效的直播Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ScanSysCloseLive{
	private static ScanSysCloseLiveBean scansyscloseliveBean;
	private static ScanSysCloseLiveCall scansyscloseliveCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("job扫描已失效的直播Test");
	}

	@Before
	public void caseUp() {
		scansyscloseliveBean=new ScanSysCloseLiveBean();
		scansyscloseliveCall=new ScanSysCloseLiveCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(scansyscloseliveCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ScanSysCloseLive_001() {
		Logger.start(true,"正确数据，成功");
		try {
			List<Userinfo> list = new JUserWapper().select1KSeller();
			Userinfo uinfo = list.get(0);
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(uinfo));
			LiveRoom createlive1 = LiveRoomCallService.CreateSellerLive(LiveRoomCallService.initCreatesellerliveBean(uinfo), false);
			LiveRoom dblive = new LiveRoomWapper().selectLiveRoomById(createlive.getId());
			LiveRoom dblive1 = new LiveRoomWapper().selectLiveRoomById(createlive1.getId());
			Logger.verifyEquals(0, dblive.getLiveStatus(), "验证直播状态");
			Logger.verifyEquals(0, dblive1.getLiveStatus(), "验证直播状态");
			LiveRoomCallService.SellerLiveOnline(createlive.getId(), uinfo.getUserId());
			scansyscloseliveBean.setUserId(uinfo.getUserId());
			scansyscloseliveCall.setData(scansyscloseliveBean);
			scansyscloseliveCall.callService();
			Logger.verifyEquals("ok", scansyscloseliveCall.getReturnData(), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}